<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge" />
<link rel="shortcut icon" href="/static/style/images/favicon.ico" />
<!-- [my97日期时间控件] -->
<script type="text/javascript" src="/static/My97DatePicker/WdatePicker.js" charset="utf-8"></script>
<!-- [EasyUI] -->
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/easyui/themes/gray/easyui.css" />
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css" />
<script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
<!-- [扩展样式] -->
<link rel="stylesheet" type="text/css" href="/static/style/css/dreamlu.css" />
<link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
<link rel="stylesheet" type="text/css" href="/static/style/css/login.css" />
<!--<script type="text/javascript" src="static/js/login.js" charset="utf-8"></script>-->
<title>用户管理</title>
<script type="text/javascript">
    var dataGrid;
    var organizationTree;

    $(function () {
        function GetDateStr(AddDayCount) {
            var dd = new Date();
            dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
            var y = dd.getFullYear();
            var m = dd.getMonth()+1;//获取当前月份的日期
            var d = dd.getDate();
            return y+"-"+m+"-"+d;
        }
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        var start_date = getUrlParam('start');
        var end_date = getUrlParam('end');
        if (start_date && end_date){
          $('#start').datebox('setValue', start_date);
          $('#end').datebox('setValue', end_date);
        }else{
          $('#start').datebox('setValue', GetDateStr(-30));
          $('#end').datebox('setValue', GetDateStr(-1));
        }

        //首次进入拉取
        dataGrid = $('#dataGrid').datagrid({
            url: '/versioncnt',
            method:'get',
            fit: true,
            striped: true,
            rownumbers: true,
            singleSelect: true,
            pageSize: 100,
            pageList: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
            queryParams: {
                start: $('#start').val(),
                end: $('#end').val()
            },
            columns: [[{
                width: '40%',
                title: '客户端',
                field: 'product_type',
                formatter: function(value,row,index){
				if (row.product_type == 7){
					return '化工';
				} else if (row.product_type == 8) {
					return '农业';
				}else if (row.product_type == 9) {
					return '金属';
				}else{
                    return '短讯';
                }
			}
            }, {
                width: '30%',
                title: '版本',
                field: 'version',
                sortable: false
            }, {
                width: '30%',
                title: '签到用户数',
                field: 'cnt',
                sortable: false
            }]],
            toolbar: '#toolbar'
        });
        });


        function searchFun() {
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }
        function cleanFun() {
            $('#searchForm input').val('');
            dataGrid.datagrid('load', {});
        }

        function export_excel() {
            location.href="/exportversioncnt?start="+$('#start').val()+'&end='+$('#end').val()+'&merchant_type='+$('#merchant_type').val();
        }
    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
<div data-options="region:'north',border:false" style="height: 30px; overflow: hidden;background-color: #fff">
  <form id="searchForm">
    <table>
      <tr>
        <th>请选择查询范围:</th>
        <!--<td><input name="rq" placeholder=""/></td>-->
        <td><input id="start" name="start" type="text" class="easyui-datebox" required="required"></td>
          <td><span>至</span></td>
        <td><input id="end" name="end" type="text" class="easyui-datebox" required="required"></td>
        <td>

            <a href="javascript:void(0);" class="easyui-linkbutton"
               data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">查询</a><a
                href="javascript:void(0);" class="easyui-linkbutton"
                data-options="iconCls:'icon-cancel',plain:true" onclick="cleanFun();">清空</a>
        </td>
      </tr>
    </table>
  </form>
</div>
<div data-options="region:'center',border:false,title:''">
  <table id="dataGrid" data-options="fit:true,border:false">
  </table>
</div>

<div id="toolbar" style="display: none;">
  <a onclick="export_excel();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-sum'" style="float:right">导出Excel</a>
 </div>
<!--<div id="toolbar" style="display: none;"> <a onclick="javascript :history.back(-1);" href="javascript:void(0);" class="easyui-linkbutton"-->
           <!--data-options="plain:true,iconCls:'icon-back'">返回</a>-->

 <!--</div>-->


</body>
</html>
